Component({
    properties: {
        keyCol:{type:String,value:'title'},
        valueCol:{type:String, value:'id'},
        options:{type:Array|null, value:null},
        value:{type:Array|String|null, value:''},
        placeholder: {type:String, value:"请选择"}
    },
    data: {
        _show:false,
        _value: [],
        _keys:{},
        _options:null,
    },
    lifetimes:{
        attached() {
            (async ()=>{
                const {keyCol, valueCol} = this.data
                this.setData({
                    _keys:{
                        label:keyCol,
                        value: valueCol,
                    }
                })
            })()
        }
    },
    observers:{
        'options, value':function (options, value){

            console.log("aaaaa", options, value)
            const {keyCol, valueCol} = this.data

            // const index = options.findIndex(item => {
            //     item[valueCol] = value
            // })
            this.setData({
                _options:options,
                _value: value ? value : [],
            })
        }
    },
    methods: {
        pickerClick(){
            console.log("dianheee",this.data)
          this.setData({
              _show:true,
          })
        },
        bindChange(e){
            console.log("change",e)

            this.setData({
                _value: e.detail.value,
            });

            this.triggerEvent('change', {

            })
        }
    }
});
